package io.gitee.mojingjiao.day05;

import org.junit.Test;

import java.util.*;

public class DemoList {
    public static void main(String[] args) {
            String text="Teach Yourself Programming in Ten Years\n" +
                    "Researchers (Bloom (1985), Bryan & Harter (1899), Hayes (1989),\n" +
                    "Simmon & Chase (1973)) have shown it takes about ten years to\n" +
                    "develop expertise in any of a wide variety of areas, including\n" +
                    "chess playing, music composition, telegraph operation, painting,\n" +
                    "piano playing, swimming, tennis, and research in neuropsychology\n" +
                    "and topology. The key is deliberative practice: not just doing it\n" +
                    "again and again, but challenging yourself with a task that is just\n" +
                    "beyond your current ability, trying it, analyzing your performance\n" +
                    "while and after doing it, and correcting any mistakes. Then repeat.\n" +
                    "And repeat again. There appear to be no real shortcuts: even\n" +
                    "Mozart, who was a musical prodigy at age 4, took 13 more years\n" +
                    "before he began to produce world-class music. In another genre, the\n" +
                    "Beatles seemed to burst onto the scene with a string of #1 hits and\n" +
                    "an appearance on the Ed Sullivan show in 1964. But they had been\n" +
                    "playing small clubs in Liverpool and Hamburg since 1957, and while\n" +
                    "they had mass appeal early on, their first great critical success,\n" +
                    "Sgt. Peppers, was released in 1967.";
            String[]textArray=text.split("[,. ]");
        System.out.println(Arrays.toString(textArray));
        Map<String,Integer>textMap=new HashMap<>();
        for(int i=0;i<textArray.length;i++){
            String key=textArray[i].toLowerCase();
            if(null==textMap.get(key)){
                textMap.put(key,1);
            }else {
                Integer count=textMap.get(key);
                textMap.put(key,count+1);
            }
        }
//
//    } Integer< Map.Entry<String,Integer>> iterator=textMap.entrySet().iterator();
//        while(iterator.hasNext()){
//            Map.Entry<String,Integer>item=iterator.next();
//            System.out.println(item.getKey()+"出现了"+item.getValue()+"次");
        }

}
